Ext.define('component.customer.cusInfoPanel', {
	extend : 'Ext.form.Panel',
	initComponent:function(){
	var custemInfo = Ext.create('Ext.form.FormPanel',{
		collapsible: true,  //可折叠
		autoScroll:false,
		defaults: {
			anchor: '100%',
		},
	    fieldDefaults: {
	    	margin: 2
	    },
	    title:'客户购房需求',
		xtype : "container",
		layout : "hbox",
		items: [{
			items: [{
				xtype:'displayfield',  
	            fieldLabel:'置业动机',  
	            minWidth:500,
    			name:'dongjiName'
            },{
	            xtype:'displayfield',  
	            fieldLabel:'需求面积',  
	            minWidth:500,
    			name:'mianji'
            },{
            	xtype:'displayfield',  
	            fieldLabel:'付款方式',  
    			name:'rqPaymentMethod'
            }]
        },{
        	height: 76,
            items: [{
	            xtype:'displayfield',  
	            fieldLabel:'关注重点',  
	            minWidth:500,
    			name:'zhongdianName'
            },{
	            xtype:'displayfield',  
	            fieldLabel:'生活服务',  
	            minWidth:500,
    			name:'shenghuo'
            }]
        }]
	});
	var custemInfo1 = Ext.create('Ext.form.FormPanel',{
		collapsible: true,  //可折叠
		autoScroll:false,
		defaults: {
			anchor: '100%',
	    },
	    fieldDefaults: {
	        margin: 2
	    },
	    title:'首次接触信息',
		layout: 'hbox',
		items: [{
			id:"laidian",
            items: [{
            	xtype:'displayfield',  
	            fieldLabel:'接触方式',
	            minWidth:500,
	            renderer:function(val){
                	return '首次来电';
                }
            },{
                xtype:'displayfield',
                fieldLabel: '接触时间',
	            minWidth:500,
                name: 'ftContactTimes',
                id:'ftContactTimes'
            },{
                xtype:'displayfield',
                fieldLabel: '沟通内容',
	            maxWidth:500,
                name:'ftContactContent',
                renderer : function(value, metaData, record) {
                	return  '<span title="'+value+'">'+value+'</span>';

                }
            }]
        },{
        	id:"laifang",
        	items: [{
            	xtype:'displayfield',  
	            fieldLabel:'接触方式',
	            minWidth:500,
    			name:'jiechuType'
            },{
                xtype:'displayfield',
                fieldLabel: '接触时间',
	            minWidth:500,
                name: 'ftContactTimes1',
                id:'ftContactTimes1'
            },{
                xtype:'displayfield',
                fieldLabel: '沟通内容',
	            maxWidth:500,
                name:'ftContactContent1',
                renderer : function(value, metaData, record) {
                	return  '<span title="'+value+'">'+value+'</span>';

                }
            }]
        }]
	});

	var c1 = Ext.create('Ext.form.FormPanel',{
		collapsible: true,  //可折叠
		autoScroll:false,
		defaults: {
			anchor: '100%',
	    },
	    fieldDefaults: {
	    	margin: 2
	    },
	    title:'客户个人信息',
	    layout: 'hbox',
		items: [{
            items: [{
            	items: [{
		            xtype:'displayfield',  
		            fieldLabel:'居住地',
	    			name:'jusheng',
	    			id:'jusheng',
		            minWidth:500
	            },{
		            xtype:'displayfield',  
		            fieldLabel:'工作区',
		            minWidth:500,
	    			name:'gongsheng',
	    			id:'gongsheng'
	            }]
            }]
        },{
        	height: 54,
        	width: 500,
            items: [{
            	xtype:'displayfield',
            	fieldLabel: '从事行业',
            	name: 'congshihangye'
            }]
        }]
	});

	   c1.getForm().load({
			url:jypath+'/customer/customer/findCustomerInfo',
			params:{'customerId':customerId},
			success:function(form, action){
				var obj = action.result.data;
				var juStr=String(obj.jusheng != null ? obj.jusheng : '')+String(obj.jucity!= null ?obj.jucity : '')+String(obj.juarea != null ? obj.juarea.toString() : '');
				var gongStr=String(obj.gongsheng==null?'':obj.gongsheng)+String(obj.gongcity==null?'':obj.gongcity)+String(obj.gongarea==null?'':obj.gongarea);
                Ext.getCmp("jusheng").setValue(juStr);
                Ext.getCmp("gongsheng").setValue(gongStr);
                custemInfo.getForm().setValues(obj);
                custemInfo1.getForm().setValues(obj);
				if(obj.ftContactTime !="" && obj.ftContactTime != null){
					custemInfo1.getForm().findField("ftContactTimes").setValue(Ext.Date.format(new Date(obj.ftContactTime),'Y-m-d H:i'));
				}else{
					Ext.getCmp("laidian").hide();
				}
				if(obj.ftContactTime1 !="" && obj.ftContactTime1 != null){
					custemInfo1.getForm().findField("ftContactTimes1").setValue(Ext.Date.format(new Date(obj.ftContactTime1),'Y-m-d H:i'));
				}else{
					Ext.getCmp("laifang").hide();
				}
			},   
			failure: function(form, action) {
		        Ext.Msg.alert("加载失败", action.result.errorMessage);
		    }
		});
		
		var defaultConfig = {
			defaults: {  
	            split: true,    //有分割线  
	            collapsible: true,  //可以折叠
	        },
			items:[custemInfo,custemInfo1,c1]
		};
		Ext.apply(this,defaultConfig);
		this.callParent(arguments);
	}
});
